[BUG] Fix deep_equals failing on string-dtype numpy arrays (numpy < 2.0)#519
Open
shourya1419-netizen wants to merge 9 commits intosktime:mainfrom
Open
[BUG] Fix deep_equals failing on string-dtype numpy arrays (numpy < 2.0)#519shourya1419-netizen wants to merge 9 commits intosktime:mainfrom
shourya1419-netizen wants to merge 9 commits intosktime:mainfrom
Conversation
…rya1419-netizen/skbase into test-filter-tags-regression
fkiraly
approved these changes
Apr 18, 2026
Contributor
|
Abandoned PR. Merging without added test since the fix seems reasonable. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #519 +/- ##
==========================================
- Coverage 85.07% 83.54% -1.54%
==========================================
Files 45 52 +7
Lines 3015 3913 +898
==========================================
+ Hits 2565 3269 +704
- Misses 450 644 +194 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #517
What was the bug?
deep_equalscrashed with aTypeErrorwhen comparing numpy arrayswith string dtype on numpy < 2.0.
The check
if x.dtype == "str"in_numpy_equals_pluginnever matchedin numpy < 2.0, because string arrays have dtype like
U3or<U1(not
"str"). This caused string arrays to fall through to theelsebranch which calls
np.array_equal(x, y, equal_nan=True)— andequal_nan=Trueinternally callsnp.isnan(), which does not supportstring types.
Fix
Added
np.issubdtype(x.dtype, np.character)to the dtype check, whichcorrectly catches all string dtypes across numpy versions (both < 2.0
and >= 2.0).
Testing
Added a new test file
tests/test_deep_equals.pycovering:TrueFalseAll tests pass.